package com.itheima.health.dao;

import com.itheima.health.pojo.Menu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author lenovo
 */
public interface MenuMapper extends Mapper<Menu> {
    /**
    获取父菜单项集合
    */
    @Select("SELECT t5.* FROM t_user t1 join t_user_role t2 on t1.id = t2.user_id  join t_role t3 on t3.id = t2.role_id join t_role_menu t4 on t4.role_id = t3.id  join t_menu t5 on t5.id = t4.menu_id where t1.id = #{id} and level = 1")
    List<Menu> getParentMenu(@Param("id") Integer id);

    @Select("select * from t_menu where parentMenuId = #{id}")
    List<Menu> getChildrenMenu(@Param("id") Integer id);
}
